import _root_.twinkleberry.{SongMetadata, Config}
import collection.generic.CanBuildFrom
import collection.mutable.HashSet
import io.{Codec}
import java.io.File
import java.util.Date
import twinkleberry.Util._
import twinkleberry.Config._
import xml.{XML, Source, PrettyPrinter}

object TwinkleBerryToM3u {
  def main(args:Array[String]) {
    val artists:Seq[String] = XML.load(new File(playlistRoot, "jen.xml").toURL) \ "item" map(_.getString("path"))
    val goodSongs = musicRoot.findFiles
            .filter{f:File =>  f.getName.endsWith("mp3") }
            .filter{f:File => artists.contains(SongMetadata.getArtist(f).getOrElse(1))}
            .map(_.removeRoot(musicRoot, removeLeadingSlash=true))
    
    new File(playlistRoot, "jen.m3u").write(goodSongs.mkString("../music/", "\n", ""))
  }
}